<template>
  <div class="login">
    <h2><img src="@/assets/images/login_logo.png" /></h2>
    <div class="login-form">
      <h3>登录</h3>
      <div class="form-item">
        <label>邮箱地址或手机号码</label>
        <input v-model="formData.account" />
      </div>
      <div class="form-item">
        <div class="flex flex-between">
          <label>密码</label>
          <span>忘记密码</span>
        </div>
        <input type="password" v-model="formData.password" />
      </div>
      <div class="form-btn login-btn" @click="handleLogin">登录</div>
      <p class="notice">继续操作即表示您同意亚马逊的<span>使用条件</span>和<span>隐私声明</span>。</p>
      <div class="flex remember">
        <div class="flex checkbox">
          <span></span>
          <p>记住登录状态。</p>
        </div>
        <div class="flex detail-box">
          <p>详情</p>
          <svg-icon icon-class="downArrowIcon" />
        </div>
      </div>
      <div class="form-btn register">立即注册</div>
    </div>
    <div class="footer">
      <div class="footer-border"></div>
      <ul class="flex footer-nav">
        <li>我要开店</li>
        <li>亚马逊物流</li>
        <li>Amazon Payments</li>
        <li>Amazon Advertising</li>
        <li>在欧洲销售</li>
        <li>在日本销售</li>
        <li>帮助</li>
      </ul>
      <p class="copyright">&copy; 1996-2023，Amazon.com, Inc.或其附属公司</p>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      formData: {}
    }
  },
  methods: {
    handleLogin () {
      const { account, password } = this.formData
      const token = window.encodeURIComponent(`${account}+${password}`)
      this.$store.dispatch('login', token).then(() => {
        this.$router.push('/home')
      })
    }
  }
}
</script>

<style lang="less" scoped>
.login {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 13px;
  line-height: 19px;
  color: #111;

  .login-form {
    padding: 20px 26px;
    margin: 18px 0 26px;
    border-radius: 4px;
    border: 1px solid #ddd;

    h3 {
      margin-bottom: 10px;
      font-size: 28px;
      line-height: 1.2;
    }

    .form-item {
      margin-bottom: 14px;
      label {
        padding-left: 2px;
        padding-bottom: 2px;
        font-weight: 600;
      }
      input {
        width: 100%;
        height: 31px;
        padding: 3px 7px;
        background-color: #fff;
        border-radius: 3px;
        border: 1px solid #a6a6a6;
        border-top-color: #949494;
        box-shadow: 0 1px 0 rgba(255, 255, 255, .5), 0 1px 0 rgba(0, 0, 0, .07) inset;
        outline: 0;
      }
      span {
        color: #0066c0;
        cursor: pointer;
      }
    }

    .form-btn {
      box-sizing: content-box;
      width: 100%;
      height: 29px;
      text-align: center;
      line-height: 29px;
      border-radius: 3px;
      border-color: #adb1b8 #a2a6ac #8d9096;
      border-width: 1px;
      border-style: solid;
      box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset;
      cursor: pointer;
    }

    .login-btn {
      margin-top: 22px;
      background: linear-gradient(to bottom,#f7dfa5,#f0c14b);
      border-color: #a88734 #9c7e31 #846a29;
    }
    .register {
      margin: 40px 0 14px;
      background: linear-gradient(to bottom,#f7f8fa,#e7e9ec);
    }

    .notice {
      margin: 18px 0;
      font-size: 12px;
      line-height: 18px;
      span {
        color: #0066c0;
      }
    }
    .remember {
      padding-bottom: 2px;
      .checkbox {
        span {
          width: 13px;
          height: 13px;
          margin-left: 3px;
          margin-right: 5px;
          border: 1px solid #111;
          border-radius: 2px;
        }
      }
      .detail-box {
        p {
          color: #0066c0;
        }
      }
    }
  }

  .footer {
    width: 100%;
    .footer-border {
      position: relative;
      height: 44px;
      z-index: 0;
      background: linear-gradient(to bottom,rgba(0,0,0,.14),rgba(0,0,0,.03) 3px,transparent);
      &::before {
        content: '';
        display: block;
        width: 100%;
        height: 44px;
        background: linear-gradient(to right,#fff,rgba(255,255,255,0),#fff);
        background-color: transparent;
        z-index: 1;
      }
    }

    .footer-nav {
      margin-top: -18px;
      justify-content: center;
      li {
        padding: 0 10px;
        font-size: 11px;
        color: #0066c0;
        cursor: pointer;
      }
    }

    .copyright {
      margin-top: 10px;
      font-size: 11px;
      text-align: center;
      color: #555;
    }
  }
}
</style>
